<?php

declare(strict_types=1);

/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

use Hyperf\ConfigCenter\Mode;

use function Hyperf\Support\env;

return [
    'enable' => (bool)env('CONFIG_CENTER_ENABLE', true),
    'driver' => env('CONFIG_CENTER_DRIVER', 'nacos'),
    'mode' => env('CONFIG_CENTER_MODE', Mode::PROCESS),
    'drivers' => [
        'nacos' => [
            'driver' => Hyperf\ConfigNacos\NacosDriver::class,
            'merge_mode' => Hyperf\ConfigNacos\Constants::CONFIG_MERGE_APPEND,
            'interval' => 3,
            'default_key' => 'config',
            'listener_config' => [
                // dataId, group, tenant, type, content
                'config' => [
                    'tenant' => env('NACOS_NAMESPACE_ID', 'public'), // corresponding with service.namespaceId
                    'data_id' => env('APP_NAME') . '.' . env('NACOS_CONFIG_TYPE', 'json'),
                    'group' => env('APP_ENV', 'prod'),
                    'type' => env('NACOS_CONFIG_TYPE', 'json'), // yml
                ],
            ],
            'client' => [
                // nacos server url like https://nacos.hyperf.io, Priority is higher than host:port
                // 'uri' => '',
                'host' => env('NACOS_HOST', '127.0.0.1'),
                'port' => env('NACOS_PORT', 8848),
                'username' => env('NACOS_USERNAME', 'nacos'),
                'password' => env('NACOS_PASSWORD', 'nacos'),
                'guzzle' => [
                    'config' => null,
                ],
                // Only support for nacos v2.
                'grpc' => [
                    'enable' => true,
                    'heartbeat' => 10,
                ],
            ],
        ],
    ]
];
